//package com.inspur.edp.cef.generator.coreGenerator.base.entitygen.resourceinfo;
//
//
//import com.inspur.edp.caf.generator.baseInfo.ParameterInfo;
//import com.inspur.edp.caf.generator.baseInfo.TypeInfo;
//import com.inspur.edp.caf.generator.method.ClassMethodGenerator;
//import com.inspur.edp.cef.rtgenerator.repositorygen.RepositoryGenUtil;
//import com.inspur.edp.cef.spi.entity.info.EnumValueInfo;
//import java.util.ArrayList;
//import java.util.List;
//import lombok.var;
//import org.eclipse.jdt.core.dom.AST;
//import org.eclipse.jdt.core.dom.Block;
//import org.eclipse.jdt.core.dom.ClassInstanceCreation;
//import org.eclipse.jdt.core.dom.Expression;
//import org.eclipse.jdt.core.dom.InfixExpression;
//import org.eclipse.jdt.core.dom.Modifier;
//import org.eclipse.jdt.core.dom.ParameterizedType;
//import org.eclipse.jdt.core.dom.ReturnStatement;
//import org.eclipse.jdt.core.dom.Statement;
//import org.eclipse.jdt.core.dom.StringLiteral;
//import org.eclipse.jdt.core.dom.SwitchCase;
//import org.eclipse.jdt.core.dom.SwitchStatement;
//import org.eclipse.jdt.core.dom.VariableDeclarationFragment;
//import org.eclipse.jdt.core.dom.VariableDeclarationStatement;
//
//public class GetPropEnumInfosMethodGen extends ClassMethodGenerator {
//
//  private static final String FormalParName_propName = "propName";
//  private static final String FormalParName_list = "list";
//  private DataTypeResInfoGenCtx ParentContext;
////	private static final String FormalParName_enumKey = "enumKey";
//
//  public GetPropEnumInfosMethodGen(DataTypeResInfoGenCtx parentContext) {
//    this.ParentContext = parentContext;
//
//  }
//
//  @Override
//  protected String getMethodName() {
//    return "getPropEnumInfos";
//  }
//
//  @Override
//  protected TypeInfo getReturnType() {
//    TypeInfo typeInfo = new TypeInfo(List.class.getTypeName());
//    typeInfo.setIsParameterizedType(true);
//    typeInfo.getArguments().add(new TypeInfo(EnumValueInfo.class));
//    return typeInfo;
//  }
//
//  @Override
//  protected ArrayList<Modifier.ModifierKeyword> getAccessModifiers() {
//    return RepositoryGenUtil.createModifierKeywordArray(Modifier.ModifierKeyword.PUBLIC_KEYWORD);
//  }
//
//  @Override
//  protected ArrayList<ParameterInfo> getParameterCollection() {
//    return new ArrayList<ParameterInfo>(java.util.Arrays.asList(new ParameterInfo[]{
//        RepositoryGenUtil.createParameterInfo(String.class, FormalParName_propName)}));
//  }
//
//
//  ///#region methodBody
////        方法1-模型显示值
////		public override List<EnumValueInfo> getPropEnumInfos(string propName)
////		{
////	        List<EnumValueInfo> list=new ArrayList<>();
////			switch (propName)
////			{
////                //枚举
////				case "key1":
////                  infos.add(new EnumInfo1());
////                  infos.add(new EnumInfo2());
////					return infos;
////				default:
////					throw new RuntimeException($"当前属性不是枚举字段，或不存在该属性名称：{propName}");
////			}
////		}
//  @Override
//  protected Block buildMethodBody() {
//    Block block = ast.newBlock();
//    setNewListStatment(block);
//
//    SwitchStatement switchStatement = ast.newSwitchStatement();
//    switchStatement.setExpression(ast.newSimpleName(FormalParName_propName));
//    ParentContext.getPropEnumInfoTypes().entrySet().stream().forEach(item -> {
//      switchStatement.statements().add(createCaseStatement(item.getKey()));
//      switchStatement.statements().addAll(buildPropStatement(item.getKey()));
//    });
//
//    InfixExpression infixExpression = ast.newInfixExpression();
//    infixExpression.setOperator(InfixExpression.Operator.PLUS);
//    StringLiteral stringLiteral = ast.newStringLiteral();
//    stringLiteral.setLiteralValue("当前属性不是枚举字段，或不存在该属性名称：");
//    infixExpression.setLeftOperand(stringLiteral);
//    infixExpression.setRightOperand(ast.newSimpleName(FormalParName_propName));
//
//    SwitchCase defaultCase = ast.newSwitchCase();
//    defaultCase.setExpression(null);
//    switchStatement.statements().add(defaultCase);
//
//    switchStatement.statements()
//        .add(RepositoryGenUtil.createThrowRuntimeException(ast, infixExpression));
//
//    block.statements().add(switchStatement);
//    return block;
//  }
//
//  //	        List<EnumValueInfo> list=new ArrayList<>();
//  private void setNewListStatment(Block block) {
//    VariableDeclarationFragment variableDeclarationFragment = ast.newVariableDeclarationFragment();
//    variableDeclarationFragment.setName(ast.newSimpleName(FormalParName_list));
//
//    ClassInstanceCreation classInstanceCreation = ast.newClassInstanceCreation();
//    classInstanceCreation
//        .setType(new com.inspur.edp.caf.generator.baseInfo.TypeInfo(ArrayList.class).getType(ast));
//    variableDeclarationFragment.setInitializer(classInstanceCreation);
//
//    VariableDeclarationStatement variableDeclarationStatement = ast
//        .newVariableDeclarationStatement(variableDeclarationFragment);
//    ParameterizedType parameterizedType = ast.newParameterizedType(
//        new com.inspur.edp.caf.generator.baseInfo.TypeInfo(ArrayList.class).getType(ast));
//    parameterizedType.typeArguments()
//        .add(new com.inspur.edp.caf.generator.baseInfo.TypeInfo(EnumValueInfo.class).getType(ast));
//    variableDeclarationStatement.setType(parameterizedType);
//
//    block.statements().add(variableDeclarationStatement);
//  }
//
//  //                  infos.add(new EnumInfo1());
//  //                  infos.add(new EnumInfo2());
//  //					return infos;
//  //
//  private ArrayList<Statement> buildPropStatement(String propName) {
//    ArrayList<Statement> list = new ArrayList<>();
//    ParentContext.getPropEnumInfoTypes().get(propName).entrySet().stream().forEach(item -> {
//      list.add(createAddToListStatement(ast, createNewInstance(ast, item.getValue()),
//          item.getKey()));
//    });
//    ReturnStatement returnStatement = ast.newReturnStatement();
//    returnStatement.setExpression(RepositoryGenUtil.createVariableLiteral(ast, FormalParName_list));
//    list.add(returnStatement);
//    return list;
//  }
//
//
//  /**
//   * list.add(new XXX());
//   *
//   * @return
//   */
//  private Statement createAddToListStatement(AST ast, Expression expression, String enumKey) {
//    List arguments = java.util.Arrays.asList(expression);
//    return ast.newExpressionStatement(RepositoryGenUtil.createMethodInvocation(ast,
//        ast.newSimpleName(FormalParName_list), "add", arguments));
//  }
//
//  private Statement createCaseStatement(String enumKey) {
//    SwitchCase switchCase1 = ast.newSwitchCase();
//    StringLiteral stringLiteral = ast.newStringLiteral();
//    stringLiteral.setLiteralValue(enumKey);
//    switchCase1.setExpression(stringLiteral);
//    return switchCase1;
//  }
//
//  private Expression createNewInstance(AST ast, TypeInfo typeInfo) {
//    var creation = ast.newClassInstanceCreation();
//    creation.setType(ast.newSimpleType(ast.newName(typeInfo.getTypeFullName())));
//    return creation;
//  }
//
//  ///#endregion
//}